export default function (fn, delay = 1000) {
	let lastTime = 0
	const _throttle = function (...args) {
		return new Promise((resolve, reject) => {
			let nowTime = new Date().getTime()
			let remainTime = delay - (nowTime - lastTime)
			if (remainTime <= 0) {
				const result = fn.apply(this, args)
				resolve(result)
				lastTime = nowTime
			}
		})
	}
	return _throttle
}
